package com.wolf.serialization;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;

/**
 * @auth: dylan
 * @Desc:
 * @Time: 2024/4/30
 */
public class JsonSerializer implements Serializer {
    @Override
    public byte[] serializer(Object data) {
        return JSON.toJSONBytes(data);
    }

    @Override
    public <T> T deSerializer(byte[] bytes, Class<T> clazz) {
        return JSON.parseObject(bytes, clazz, JSONReader.Feature.SupportClassForName);
    }
}
